<?php
abstract class system_controller_action_helper_abstract {
	protected $_actionController = null;
	protected $_frontController = null;
	
	public function setActionController(system_controller_action $actionController = null) {
		$this->_actionController = $actionController;
		return $this;
	}
	/**
	 * @return system_controller_action
	 */
	public function getActionController() {
		return $this->_actionController;
	}
	public function getFrontController() {
		return system_controller_front::getInstance();
	}
	public function init() {
	}
	public function preDispatch() {
	}
	public function postDispatch() {
	}
	public function getRequest() {
		$controller = $this->getActionController();
		if(null===$controller) {
			$controller = $this->getFrontController();
		}
		return $controller->getRequest();
	}
	public function getResponse() {
		$controller = $this->getActionController();
		if(null===$controller) {
			$controller = $this->getFrontController();
		}
		
		return $controller->getResponse();
	}
	public function getName() {
		$full_class_name = get_class($this);		
		if(strpos($full_class_name, '_')!==false) {
			$helper_name = strrchr($full_class_name, '_');
			return ltrim($helper_name, '_');
		} else {
			return $full_class_name;
		}
	}
}
